<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>自定义函数</title>
    <meta charset="UTF-8">
    <script type="text/javascript" src="../../static/template.js"></script>
</head>
<body>
<div id="app"></div>
<script type="text/html" id="test">


    {{if isAdmin=="a"}}
    姓名：<span>{{admin.name}}</span><br>
    性别：<span>{{getSex(admin.sex)}}</span><br>
    职务：<span>{{admin.position}}</span>
    {{else if isAdmin== "b" }}
    姓名：<span>{{boss.name}}</span><br>
    性别：<span>{{getSex(boss.sex)}}</span><br>
    职务：<span>{{boss.position}}</span>
    {{else }}
    姓名：<span>{{staff.name}}</span><br>
    性别：<span>{{getSex(staff.sex)}}</span><br>
    职务：<span>{{staff.position}}</span>
    {{/if}}
</script>
<script type="text/javascript">
    template.helper('getSex',function (sex) {
        if(1 == sex){
            return '男';
        }else if(0 == sex){
            return '女';
        }
    })
    data = {
        isAdmin: "b",
        admin: {name: '张三', sex: '1', position: "部门经理"},
        staff: {name: '李四', sex: '0', position: "普通员工"},
        boss:{name:"王五",sex:"1",position:"老板"}
    }
   var  html = template('test',data);
    document.getElementById("app").innerHTML = html;
</script>
</body>
</html>